%{
	/*
	 *  parser.y
	 */
#include <string.h>
#include <math.h> 
#include <stdio.h>
#include <stdlib.h>
#include "automata.h"

//maximum number of variables is MAXCOL
//maximum possible length of trace is MAXROW
#define MAXCOL 50
#define MAXROW 10000



	int yyparse(void);
	extern int yylex(void);
	extern void yyerror(char*);

	//Defined in lexer.l
	//Tracks location of possible error
	extern int line, col; 

	//Defined in lexer.l
	//Adds new entry to hash table
	//Can also be used to search old entries from hash table
	extern int addtohash(char* s);


 
	/*
	  Need to add a purpose here
	*/
	float getdata(node automata, float data[MAXCOL][MAXROW], int n, int m , int t);


	/*
	  Need to add a purpose here
	*/
	float simulate(node automata, float data[MAXCOL][MAXROW], int n , int m, int t);


	/*
	Need to add a purpose here
	*/
	node generate_node(int trueorfalse, node middlenode, int acceptorreject);
	/*
	  Initialize the hashtable
	*/
	char hashtable[MAXHASHSIZE][MAXHASHENTRYLEN];
	int hashcount=-1;


	char name[MAXHASHSIZE][MAXHASHENTRYLEN];
	int globalid=0;
	int t=0;
	int oldtime=-1;
	int newtime=-1;
	float arithopdata;
	node automata;

	%}

%token FUTURE
%token RECORDTIME
%token GLOBAL
%token UNTIL
%token NEXT
%token AND
%token OR
%token NOT
%token LBR
%token RBR
%token LSQBR
%token RSQBR
%token LCBR
%token RCBR
%token DIV
%token MUL
%token SUB
%token ADD
%token IDENTIFIER
%token INTEGER
%token COMPARATOR

%left FUTURE GLOBAL UNTIL NEXT AND OR NOT LBR RBR LSQBR RSQBR ADD SUB MUL DIV RECORDTIME



%start Automata
%%

Automata:

Automata AND Automata {
#ifndef PERFORMANCE
	printf("\n Automata AND Automata read\n");
#endif
/// AND node with 2 children and no variables and no final/accept/reject

	node newnode = malloc (sizeof(struct nodedash)); 
	(newnode->nodeid) = newnodeid(); 
	newnode->nodetype = AAND; 
	newnode->succ1=(node)$1; 
	newnode->succ2=(node)$3; 
	newnode->nodevar=-1; 
	newnode->accept=-1;
	$$ = newnode; 
	automata = newnode;
	

#ifndef PERFORMANCE
	printf("\n Automata AND Automata compiled\n");
#endif

}

|

RECORDTIME Automata 
{
	node newnode = malloc (sizeof(struct nodedash)); (newnode->nodeid) = newnodeid(); newnode->nodetype = ARECORD; newnode->succ1=$2; newnode->succ2=NULL; newnode->nodevar=-1; $$ = newnode;automata = newnode;
		/// RECORDTIME Automata
}

| Automata OR Automata {
#ifndef PERFORMANCE
	printf("\n Automata OR  Automata read\n");
#endif


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AOR; 
 newnode->succ1=(node)$1; 
 newnode->succ2=(node)$3; 
newnode->nodevar=-1;
 newnode->accept=-1; 
$$ = newnode;
automata = newnode;


	/// OR node with 2 children and no variables and no final/accept/reject
#ifndef PERFORMANCE
	printf("\n Automata OR Automata compiled\n");
#endif

}

| NOT Automata {
#ifndef PERFORMANCE
	printf("\n Not Automata read\n");
#endif


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = ANOT; 
newnode->succ1=$2; 
newnode->succ2=NULL; 
newnode->nodevar=-1; 
newnode->accept=-1; 
$$ = newnode;
automata = newnode;

	/// NOT node with 1 left child and no variables and no final/accept/reject
	/// should not reach here with a formula as Automata if formula is normalized. Advise report error in that case.


#ifndef PERFORMANCE
	printf("\n NOT Automata compiled\n");
#endif

}

| LBR Automata RBR {
#ifndef PERFORMANCE
	printf("\n ( Automata ) read\n");
#endif

node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = ABR; 
newnode->succ1=$2; 
newnode->succ2=NULL; 
newnode->nodevar=-1; 
newnode->accept=-1;
$$ = newnode;
automata = newnode;
	/// Bracketed node with 1 left child and no variables and no final/accept/reject 


#ifndef PERFORMANCE
	printf("\n ( Automata ) compiled\n");
#endif
}

| NEXT Automata {
#ifndef PERFORMANCE
	printf("\n NEXT Automata read\n");
#endif


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid();
 newnode->nodetype = AX; 
newnode->succ1=NULL; 
newnode->succ2=$2; 
newnode->nodevar= CTRUE; 
newnode->accept = CFALSE; 
$$ = newnode;
automata = newnode;
	/// NEXT \phi node with variable TRUE and reject and right automata for \phi 


#ifndef PERFORMANCE
	printf("\n NEXT Automata compliled\n");
#endif

}

| GLOBAL Automata {

#ifndef PERFORMANCE
	printf("\n GLOBAL Automata read\n");
#endif

node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AG; 
newnode->succ2=$2; 
newnode->succ1=generate_node(CTRUE,newnode,CTRUE); 
newnode->nodevar=-1;
newnode->accept=-1;
$$=newnode;
automata = newnode;
	/// Global phi node is an AND node with left node as itself and right node as phi. Left node is true , G phi, accepting.


#ifndef PERFORMANCE
	printf("\n GLOBAL Automata compiled\n");
#endif
}

| FUTURE Automata {

#ifndef PERFORMANCE
	printf("\n FUTURE Automata read\n");
#endif

node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AF; 
newnode->succ2=$2; 
newnode->succ1=generate_node(CTRUE,newnode,CFALSE); 
newnode->nodevar=-1;
 newnode->accept=-1;
$$=newnode;
automata = newnode;
	/// Future phi node is an OR node with left node as itself and right node as phi. Left node is true , F phi, rejecting. 

#ifndef PERFORMANCE
	printf("\n FUTURE Automata compiled\n");
#endif

}

| LCBR Automata COMPARATOR INTEGER RCBR {


#ifndef PERFORMANCE
	printf("\n LCBR Automata COMPARATOR INTEGER RCBR read\n");
#endif


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = ACOMP; 
newnode->succ1=$2; 
newnode->succ2=$4; 
newnode->nodevar = -1; 
newnode->succ3=$3; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode; 
printf("Comparator: %d\n",$3);

	/// Comparator node with comparator identifier, and final and central automata as epsilon; has two children used to store the identifier and the integer
	/// Maybe chage the idenitifer node to comparator-identifier and prevent a recursive call for code optimization

#ifndef PERFORMANCE
	printf("\n LCBR Automata COMPARATOR Automata RCBR compiled\n");
#endif
}

| IDENTIFIER {

#ifndef PERFORMANCE
	printf("\n IDENTIFIER read\n");
#endif

node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AID; 
newnode->succ1=NULL; 
newnode->succ2=NULL; 
newnode->nodevar= $1; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode;

	/// Identifier node with variable identifier, and final and central automata as epsilon 

#ifndef PERFORMANCE
	printf("\n IDENTIFIER compiled\n");
#endif
}

| INTEGER {
#ifndef PERFORMANCE
	printf("\n INTEGER read\n");
#endif 


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AINTEGER; 
newnode->succ1=NULL; 
newnode->succ2=NULL; 
newnode->nodevar= $1; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode;
	/// Integer node with integer, and final and central automata as epsilon

#ifndef PERFORMANCE
	printf("\n INTEGER compiled\n");
#endif 
}

| Automata ADD Automata {
#ifndef PERFORMANCE
	printf("\n ADD read\n");
#endif 


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AADD; 
 newnode->succ1=(node)$1; 
 newnode->succ2=(node)$3; 
newnode->nodevar= $2; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode;
	/// AADD node with identifier and identifier


#ifndef PERFORMANCE
	printf("\n ADD compiled\n");
#endif 
}

| Automata SUB Automata {

#ifndef PERFORMANCE
	printf("\n SUB read\n");
#endif 

node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = ASUB; 
 newnode->succ1=(node)$1; 
 newnode->succ2=(node)$3; 
newnode->nodevar= $2; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode;
	/// ASUB node with identifier and identifier


#ifndef PERFORMANCE
	printf("\n SUB compiled\n");
#endif 

}

| Automata MUL Automata {

#ifndef PERFORMANCE
	printf("\n MUL read\n");
#endif 


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AMUL; 
 newnode->succ1=(node)$1; 
 newnode->succ2=(node)$3; 
newnode->nodevar= $2; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode;
	/// AMUL  node with identifier and identifier


#ifndef PERFORMANCE
	printf("\n MUL compiled\n");
#endif 
}

| Automata DIV Automata {

#ifndef PERFORMANCE
	printf("\n DIV read\n");
#endif 

node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = ADIV; 
 newnode->succ1=(node)$1; 
 newnode->succ2=(node)$3; 
newnode->nodevar= $2; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode;

	/// ADIV node with identifier and identifier



#ifndef PERFORMANCE
	printf("\n DIV compiled\n");
#endif 
}


| COMPARATOR {

#ifndef PERFORMANCE
	printf("\n COMPARATOR read\n");
#endif 

node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = ACOMPARATOR; 
newnode->succ1=NULL; 
newnode->succ2=NULL; 
newnode->nodevar= $1; 
newnode->accept = CFINAL; 
$$ = newnode;
automata = newnode;
	/// Integer node with integer, and final and central automata as epsilon 

#ifndef PERFORMANCE
	printf("\n COMPARATOR compiled\n");
#endif 

}

| LSQBR Automata UNTIL Automata RSQBR {

#ifndef PERFORMANCE
	printf("\n LSQBR Automata UNTIL Automata RQSBR read\n");
#endif 


node newnode = malloc (sizeof(struct nodedash)); 
(newnode->nodeid) = newnodeid(); 
newnode->nodetype = AU; 
newnode->succ1=$4;


	///get the complex right child in shape
	newnode->succ2=malloc (sizeof(struct nodedash));


	(newnode->succ2->nodeid) = newnodeid();
	newnode->succ2->nodevar=-1;
	newnode->succ2->nodetype=AUCHILD;

	node cchild = newnode->succ2;
	cchild->succ1 = generate_node(CTRUE,newnode,CFALSE);
	cchild->succ2 = $2;


	$$ = newnode; 
	automata = newnode;
	
	///a U b is an OR node with 1 left child b and a right AND child with 2 children - left (true, aUb, reject) and right "a" variable.


#ifndef PERFORMANCE
	printf("\n LSQBR Automata UNTIL Automata RQSBR compiled\n");
#endif 

}

;

%%
int main(int argc, char **argv)
{

	FILE *fp;
	float data[MAXCOL][MAXROW];

	int i,j;

	int output;
	int n,m; ///n variables, m points
	

	extern node automata; //defined in automata.h
	extern int addtohash(char* s); //defined in lexer.l

	fp = fopen (argv[1],"r");
	if (fp==NULL)
	  {
	    printf("File %s not found in current path\nExiting...\n",argv[1]);
	    exit(-1);
	  }

	fscanf(fp," %d %d ", &n, &m );
#ifndef PERFORMANCE
	printf("DATA FILE %s :\n Number of variables: %d  Trace Length: %d\n",argv[1],n,m);
#endif

	/*
	  store the header with time in name[0] and variables in name[1] through name[n]
	*/
	for(j=0;j<n+1;j++)
	{
		fscanf(fp," %s ", name[j]);

#ifndef PERFORMANCE
		printf("%s \n ", name[j]);
#endif

	}


	/*
	  store the data with data[j][i] storing the jth variable at the ith simulation point
	*/

	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			fscanf(fp," %f ", &data[j][i]);
#ifndef PERFORMANCE
			printf("%f ", data[j][i]);
#endif

		}
#ifndef PERFORMANCE
		printf("\n");
#endif
	}


	fclose(fp);
#ifndef PERFORMANCE
	printf("\n Trace Data file read\n");
#endif

#ifndef PERFORMANCE
	printf("\n Reading the Input LTL file ... \n");
#endif

	/*Built the automata from the LTL parser */
	yyparse();



#ifndef PERFORMANCE
	printf("\n Input LTL file read. Automata compiled. \n");
#endif
	output = (int) simulate(automata,data,n,m,t); 

	/*data[VARIABLES][DATA-POINTS] with n variables and m inputs*/

#ifndef PERFORMANCE
	printf("\n Simulation Done. Returning %d \n", output );
#endif

	return(output);

}



/* Increment the global counter that is used to assign new node IDs  */

int newnodeid() {

	return globalid++;
}



/*code to generate the ASPECIAL node for AU, AF and AG*/

node generate_node(int trueorfalse, node middlenode, int acceptorreject) {
	node newnode = malloc(sizeof(struct nodedash));
	(newnode->nodeid) = newnodeid();
	newnode->nodetype = ASPECIAL;
	newnode->succ1=middlenode;
	newnode->succ2=NULL;

	newnode->nodevar= trueorfalse;
	newnode->accept = acceptorreject;

	return newnode;

}




int find(int index, int total) {
	int i, j, k;

#ifndef PERFORMANCE
	printf("\n Function find: finding hashtable[%d] in  %d names:\t total hashtable entry %d\n",index,total,hashcount);
#endif	
	for (i=0;  i<=total; i++) {
		if (!strcmp(name[i], hashtable[index])) {
#ifndef PERFORMANCE			
			printf("\n Function find: Compared %s with %s and succeded\n",name[i], hashtable[index] );
#endif				
			return i-1;  //correction for the extra # --- JHA NOTE HERE _ JHA JHA ERROOR SOURCE POTENTIAL

		}

#ifndef PERFORMANCE
		else
			printf("\n Function find: Compared %s with %s and failed\n",name[i], hashtable[index] );
#endif	
	}
#ifndef PERFORMANCE
	printf(
			"\n Function find: Variable %s in LTL did not match any name in simulation data. Aborting.\n Probably LTL property needs to be fixed.\n\n",
			hashtable[index]);
#endif	

	exit(-1);

}




/* The main simulate function  */

float simulate(node automata, float data[MAXCOL][MAXROW], int n, int m, int t) {
	int out;
	int i, j, k, l;
	int x, y, z;
	int tempint;

	///write simulation routine here
#ifndef PERFORMANCE
		printf("\n Function Simulate: Current Simulation Time %d\n",t);
#endif


	switch (automata->nodetype) {


	case AAND:

	  tempint = (int) simulate(automata->succ1, data, n, m, t)
	    && (int) simulate(automata->succ2, data, n, m, t);

#ifndef PERFORMANCE
		printf("\n Function Simulate: Node AAND read. Returning %d\n",tempint);
#endif
		return (tempint  );
		break;




	case AOR:
#ifndef PERFORMANCE
		printf("\n Function Simulate: Node AOR read\n");
#endif
		return ( (int) simulate(automata->succ1, data, n, m, t)
				|| (int) simulate(automata->succ2, data, n, m, t) );
		break;



	case ANOT:
#ifndef PERFORMANCE
		printf("\n Function Simulate: Node ANOT read\n");
#endif
		return (! ((int) simulate(automata->succ1, data, n, m, t)) );
		///may be add an warning about negation normal form.
		break;

		


	case ARECORD:
		
#ifndef PERFORMANCE
		printf("\n Function Simulate: Node ARECORD read\n");
#endif	
		
		while(t<m-1)
		{
			
			tempint = (int) simulate(automata->succ1, data, n, m, t) ;
		
			if (tempint>0 && oldtime==-1 )
				{
				oldtime = data[0][t] ;
				}
			else 
			
			{
				if ( tempint > 0 && oldtime>=0)
				{
					newtime = data[0][t] ;
				}
				else if ( tempint < 0 && oldtime>=0)
				{
					oldtime=-2; break;
				}
			}
			t++;
		}
		if (newtime>0 && oldtime>=0)	
			return(newtime-oldtime);
		else
			return 0;
		
		break;
		




	case ABR:

#ifndef PERFORMANCE
		printf("\n Function Simulate: Node ABR read\n");
#endif

		return (simulate(automata->succ1, data, n, m, t) );

		break;




	case AID:
		///AID is of the form propositionID, NULL , accept
		/// NULL automata 

#ifndef PERFORMANCE
		printf(
				"\n Function Simulate: Node AID read with variable %d at time %d\n", automata->nodevar, t);
#endif


		if (automata->nodevar>=0) {


#ifndef PERFORMANCE
			printf(
					"\n Function Simulate: Got data %d from Node AID read with variable %d at time %d\n",
					data[find(automata->nodevar,n)][t], automata->nodevar, t);
#endif

			return (data[find(automata->nodevar,n)][t]);

		} else {
			printf("Error Simulator: Function Simulate: Case AID . Variable < 0");
			exit(-1);
		}

		break;





	case ACOMP:

#ifndef PERFORMANCE
		printf("\n Function Simulate: Node ACOMP read\n");
#endif	

		if (automata->nodevar==-1) {

#ifndef PERFORMANCE
			printf(
					"\n Function Simulate: Node ACOMP: Cpmarision at TableEntry %d \n",
					(automata->succ3));
#endif	



		//GREATER THAN

       		if ( !strcmp(hashtable[(int) (automata->succ3)], ">") ) {


#ifndef PERFORMANCE
				printf("\n Function Simulate: Node ACOMP read, Saw > comparision \n");
#endif	

				arithopdata = getdata(automata->succ1,data,n,m,t);

				return ( arithopdata > strtod(
						hashtable[(int)(automata->succ2)], NULL) );

			}



		//LESS THAN


			if (!strcmp(hashtable[(int) (automata->succ3)], "<")) {
#ifndef PERFORMANCE
				printf("\n Function Simulate: Node ACOMP read, Saw < comparision \n");
#endif
				
				arithopdata = getdata(automata->succ1,data,n,m,t);
	
				printf("\n Function Simulate: Node ACOMP < read, Data Read %f < %f : returning %d  \n",arithopdata,strtod( hashtable[(int)(automata->succ2)], NULL) , arithopdata  < strtod( hashtable[(int)(automata->succ2)], NULL) );

				return ( arithopdata  < strtod(
						hashtable[(int)(automata->succ2)], NULL) );

			}





		//LESS THAN EQUAL TO


			if (!strcmp(hashtable[(int) (automata->succ3)], "<=")) {
			  printf("Hi\n");
				
				arithopdata = getdata(automata->succ1,data,n,m,t);

#ifndef PERFORMANCE
				printf("\n Function Simulate: Node ACOMP read, Saw <= comparision %f with %f\n",arithopdata, strtod(hashtable[(int)(automata->succ2)], NULL) ) ;
#endif
				return (arithopdata <= strtod(
						hashtable[(int)(automata->succ2)], NULL) );

			}





		//GREATER THAN EQUAL TO			


			if (!strcmp(hashtable[(int) (automata->succ3)], ">=")) {


				arithopdata = getdata(automata->succ1,data,n,m,t);
#ifndef PERFORMANCE
					printf("\n Function Simulate: Node ACOMP read, Saw >= comparision %f with %f\n",arithopdata, strtod(hashtable[(int)(automata->succ2)], NULL) ) ;
					//printf("\n Function Simulate: Node ACOMP read, Saw >= comparision \n");
#endif

				return ( arithopdata >= strtod(
						hashtable[(int)(automata->succ2)], NULL) );

			}



		//EQUAL TO


			if (!strcmp(hashtable[(int) (automata->succ3)], "=")) {
#ifndef PERFORMANCE
				printf("\n Function Simulate: Node ACOMP read, Saw = comparision \n");
#endif

			       	arithopdata = getdata(automata->succ1,data,n,m,t);
				return (arithopdata  == strtod(
						hashtable[(int)(automata->succ2)], NULL) );

			}

#ifndef PERFORMANCE
			printf("Error Simulator: Function Simulate: Case ACOMP . Did not match any comparator");
			exit(-1);
#endif			

		}

		else {
			printf("\nError Simulator: Function Simulate: Case ACOMP. Did not match any comparator\n");
			exit(-1);
		}

		break;




		//NEXT


	case AX:
		if (t<m-1) ///current time point is not the last moment of simulation
		{
			return (simulate(automata->succ1, data, n, m, t+1) );
		} else ///end of simulation seen
		{
			return CFALSE;
		}

		break;




		//FUTURE

	case AF:
	  tempint = (int) simulate(automata->succ2, data, n, m, t)
	    || (int) simulate(automata->succ1, data, n, m, t);
		
#ifndef PERFORMANCE
		
	  printf("\n Function Simulate: Node AF read. Returning %d\n",tempint);
#endif

	  return (tempint);

		break;



		//GLOBAL

	case AG:
		return ( (int) simulate(automata->succ2, data, n, m, t)
				&& (int) simulate(automata->succ1, data, n, m, t) );

		break;




		//UNTIL
	case AU:
		return ( (int) simulate(automata->succ1, data, n, m, t)
				|| (int) simulate(automata->succ2, data, n, m, t) );
		break;



		//SPECIAL NODE -- VERY SENSITIVE
		///Special helper nodes need to be simulates in context
	case ASPECIAL:

		if (t<m-1) ///current time point is not the last moment of simulation
		{
			return (simulate(automata->succ1, data, n, m, t+1) ); ///see more into future; loop back
		} else ///end of simulation seen
		{
			if (automata->accept == CTRUE)
				return 1; ///accept was CTRUE if we were to accept, CFALSE otherwise
			else
				return 0;///accept was CTRUE if we were to accept, CFALSE otherwise

		}
		break;


	case AUCHILD:
		return ( (int) simulate(automata->succ1, data, n, m, t)
				&& (int) simulate(automata->succ2, data, n, m, t) );

		break;




	}


	return out;
}





/*Get data from identifier, add, sub, and div routines*/
/*n is total number of variables read in the name[] file*/

float getdata(node automata, float data[MAXCOL][MAXROW], int n, int m , int t)
{

  printf("Nodetype %d\n",automata->nodetype );

  if (automata->nodetype == AID)
    {
#ifndef PERFORMANCE
       printf("\n Function getdata: retruning %f\n",data[find((int)automata->nodevar, n)][t] ) ;
#endif
      return (data[find((int)automata->nodevar, n)][t]); //just return the value of the identifier

    }

#ifndef PERFORMANCE
printf("Nodetype %d\n",(automata->succ1)->nodetype );
printf("Nodetype %d\n",(automata->succ2)->nodetype );
#endif

  switch(automata->nodetype)
    {
	case AADD:
		return ( getdata(automata->succ1, data, n, m, t)
	               +  getdata(automata->succ2, data, n, m, t) );
		break;


	case ASUB:
			
	        return ( getdata(automata->succ1, data, n, m, t)
	               -  getdata(automata->succ2, data, n, m, t) );
		break;

	case AMUL:
		 return ( getdata(automata->succ1, data, n, m, t)
	               * getdata(automata->succ2, data, n, m, t) );

		break;

	case ADIV:
	  printf("Read a division operation\n");

	  if (getdata(automata->succ1, data, n, m, t)==0) return 0;
	  if (getdata(automata->succ2, data, n, m, t)==0) 
	    {
	      printf("Error; ADIV saw division by zero\n\n");
	      exit(-1);
	    }

		return ( getdata(automata->succ1, data, n, m, t)
	               / getdata(automata->succ2, data, n, m, t) );

		break;
    }

  printf("Error;\n getdata() failed\n");
  exit(-1);

}
